package com.braveman.im.ui.activity;

import android.view.View;
import android.widget.ExpandableListAdapter;
import android.widget.ExpandableListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.braveman.im.R;
import com.braveman.im.bean.MyFlockChildBean;
import com.braveman.im.bean.MyFlockGroupBean;
import com.braveman.im.ui.adapter.MyFlockAdapter;
import com.braveman.im.utils.UtilsStyle;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.utils.ActivityUtils;
import com.vondear.rxtools.RxBarTool;

import java.util.ArrayList;
import java.util.List;

/**
 * 作者 昊昊.
 * 年份 2017/10/19.
 * 时间 9:28.
 * 项目名称 ZhengQiApp.
 */

/**
 * 我的群
 */
public class MyFlockActivity extends BaseActivity {
    private ExpandableListView expandableListView;
    private RelativeLayout relativeLayout;
    private MyFlockAdapter adapter;
    private List<MyFlockGroupBean> list;


    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("我的群").setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ActivityUtils.finishActivity(MyFlockActivity.this);
            }
        });
    }

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected int initContentView() {
        UtilsStyle.setStatusBarMode(this, true);
        RxBarTool.FlymeSetStatusBarLightMode(getWindow(), true);
        RxBarTool.MIUISetStatusBarLightMode(getWindow(), true);
        return R.layout.activity_my_flock;
    }

    @Override
    protected void initChildView() {
        expandableListView = (ExpandableListView) findViewById(R.id.exview_activity_listview);
        relativeLayout = (RelativeLayout) findViewById(R.id.activity_flock_rl);
    }

    @Override
    protected void initChildData() {
        list = new ArrayList<MyFlockGroupBean>();


            List<MyFlockChildBean> list1 = new ArrayList<>();
            MyFlockChildBean cb = new MyFlockChildBean("11", "231231", "321312", "312312", "321312");

            List<MyFlockChildBean> list2 = new ArrayList<>();
            MyFlockChildBean cb1 = new MyFlockChildBean("11", "13213123", "1111111", "2222222", "333333");

            List<MyFlockChildBean> list3 = new ArrayList<>();
            MyFlockChildBean cb2 = new MyFlockChildBean("11", "$$$$", "###", "###", "$$$$$");
            list2.add(cb1);
            list1.add(cb);
            list3.add(cb2);

            MyFlockGroupBean groupBean = new MyFlockGroupBean("sdas", "2312", "231231", list1);
            MyFlockGroupBean groupBean1 = new MyFlockGroupBean("sdas", "2312", "231231", list2);
            MyFlockGroupBean groupBean2 = new MyFlockGroupBean("sdas", "2312", "231231", list3);
            list.add(groupBean);
            list.add(groupBean1);
            list.add(groupBean2);

        adapter = new MyFlockAdapter(list, this);
        expandableListView.setAdapter(adapter);
        expandableListView.setGroupIndicator(null);
        expandableListView.collapseGroup(0);

        //ex控件点击事件
        expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
                if (expandableListView.isGroupExpanded(i)) {
                    relativeLayout.setVisibility(View.VISIBLE);
                    expandableListView.collapseGroup(i);
                } else {
                    relativeLayout.setVisibility(View.GONE);
                    expandableListView.isGroupExpanded(i);
                }
                return false;
            }
        });
    }

    @Override
    protected void setChildViewListener() {

    }
}
